package com.wjbgn.electronicnian.convert;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wjbgn.electronicnian.dto.NianStealDumplingsLogDTO;
import com.wjbgn.electronicnian.entity.NianStealDumplingsLogDO;
import com.wjbgn.electronicnian.util.BeanCopierUtil;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * Description: 
 * Create Date: 2022-01-21T17:38:21.072290700
 * @author weirx
 * @version 1.0
 */
@Component
public class NianStealDumplingsLogDoConvert {

    /**
     * DtoToDo
     *
     * @param nianStealDumplingsLogDTO
     * @return
     */
    public static NianStealDumplingsLogDO dtoToDo(NianStealDumplingsLogDTO nianStealDumplingsLogDTO) {
            NianStealDumplingsLogDO nianStealDumplingsLogDO = new NianStealDumplingsLogDO();
        BeanCopierUtil.copy(nianStealDumplingsLogDTO, nianStealDumplingsLogDO);
        return nianStealDumplingsLogDO;
    }

    /**
     * DoToDto
     *
     * @param nianStealDumplingsLogDO
     * @return
     */
    public static NianStealDumplingsLogDTO doToDto(NianStealDumplingsLogDO nianStealDumplingsLogDO) {
            NianStealDumplingsLogDTO nianStealDumplingsLogDTO = new NianStealDumplingsLogDTO();
        BeanCopierUtil.copy(nianStealDumplingsLogDO, nianStealDumplingsLogDTO);
        return nianStealDumplingsLogDTO;
    }

    /**
     * Page<DO> to Page<DTO>
     *
     * @param pageDO
     * @return
     */
    public static Page<NianStealDumplingsLogDTO> pageConvert(Page<NianStealDumplingsLogDO> pageDO) {
        List<NianStealDumplingsLogDTO> list = listConvert(pageDO.getRecords());
        Page<NianStealDumplingsLogDTO> page = new Page<>(pageDO.getCurrent(), pageDO.getSize(), pageDO.getTotal());
        page.setRecords(list);
        return page;
    }

    /**
     * list<DO> to list<DTO>
     *
     * @param listDO
     * @return
     */
    public static List<NianStealDumplingsLogDTO> listConvert(List<NianStealDumplingsLogDO> listDO) {
        List<NianStealDumplingsLogDTO> list = new ArrayList<>();
            NianStealDumplingsLogDTO nianStealDumplingsLogDTO;
        for (NianStealDumplingsLogDO nianStealDumplingsLogDO : listDO) {
                nianStealDumplingsLogDTO = new NianStealDumplingsLogDTO();
            BeanCopierUtil.copy(nianStealDumplingsLogDO, nianStealDumplingsLogDTO);
            list.add(nianStealDumplingsLogDTO);
        }
        return list;
    }
}